#ifndef BOARD_H
#define BOARD_H

#include <QGraphicsScene>
#include <QPen>
#include <QBrush>

#include "boarditem.h"
#include "boardfigure.h"
#include "constants.h"
#include "move.h"

class Board : public QGraphicsScene {
 public:
  Board( QObject* parent=0 );
  void addItem( BoardItem* item );

 protected:
  void mousePressEvent( QGraphicsSceneMouseEvent* event );
  Move* canMoveFigure(int, int);
  void makeMove( Move* );

 private:
  BoardFigure* selected;
  QGraphicsItem* selectedFrameItem;
  QList<QGraphicsItem*> possibleMoveFrames;

  void select( BoardItem* item );
  void unSelect();

  void showPossibleMoves( QList<Move*>& );
  void hidePossibleMoves();

  void createBoard();
  void createFields();
  void createFigures();
  QPen pen;
  QBrush brush;

  QPen possibleMovePen;
  QBrush possibleMoveBrush;

  BoardFigure* board[8][8];
};

#endif
